QuickTime 3 Reference

| Previous | Chapter Contents | Chapter Top | Next |

Obtaining a Graphics Importer Instance

GetGraphicsImporterForFile

Locates and opens a graphics importer component that can be used to draw the specified file. There are two versions of this routine: GetGraphicsImporterForFile and GetGraphicsImporterForFileWithFlags

pascal OSErr GetGraphicsImporterForFile(
    const FSSpec *theFile,
    ComponentInstance *gi);

pascal OSErr GetGraphicsImporterForFileWithFlags(
    const FSSpec *theFile,
    ComponentInstance *gi,
    long flags);

theFile     Specifies the file to be drawn using a graphics importer component.

gi     A pointer to a ComponentInstance in which the best graphics importer for working with the specified file will be returned. If no graphics importer can be found, the ComponentInstance will be set to nil .

flags     Controls the graphics importer search process. The following flag is available: kDontUseValidateToFindGraphicsImporter . If a graphics importer cannot be found using the file's type or file name suffix, give up immediately without using the slower process of asking every graphics importer to validate the file. This parameter is only used with GetGraphicsImporterForFileWithFlags

DISCUSSION

GetGraphicsImporterForFile first tries to locate a graphics importer component for the specified file based on the Macintosh file type of the file. If it is unable to locate a graphics importer component based on the Macintosh file type, and the file type is 'TEXT' , GetGraphicsImporterForFile will try to locate a graphics importer component for the specified file based on the file name extension of the file.

If it is unable to locate a graphics importer for the file, the returned ComponentInstance is set to nil . If it is able to locate a graphics importer for the file, the returned graphics importer ComponentInstance will have already been set up to draw the specified file in the current port.

If an importer cannot be found using the file type, file name suffix, or MIME type, GetGraphicsImporterForFile will ask each available graphics importer to validate the file, in hopes that one of them can handle files of this type. This can take a long time. If you do not want QuickTime to do this, use the GetGraphicsImporterForFileWithFlags function with the flag kDontUseValidateToFindGraphicsImporter.

The caller of GetGraphicsImporterForFile is responsible for closing the returned ComponentInstance using CloseComponent .

GetGraphicsImporterForDataRef

Locates and opens a graphics importer component that can be used to draw the specified data reference. There are two versions of this routine: GetGraphicsImporterForDataRef and GetGraphicsImporterForDataRefWithFlags.

pascal OSErr GetGraphicsImporterForDataRef(
            Handle dataRef,
            OSType dataRefType,
            ComponentInstance *gi);

pascal OSErr GetGraphicsImporterForDataRefWithFlags(
            Handle dataRef,
            OSType dataRefType,
            ComponentInstance *gi,
            long flags);

dataRef     Specifies the data reference to be drawn using a graphics importer component.

dataRefType     The type of the data reference specified by the dataRef parameter. For alias-based data references, the dataRef handle contains an AliasRecord, and dataRefType is equal to rAliasType .

gi     A pointer to a ComponentInstance in which the best graphics importer for working with the specified data reference will be returned. If no graphics importer can be found, the ComponentInstance will be set to nil .

flags     Controls the graphics importer search process. The following flag is available: kDontUseValidateToFindGraphicsImporter . If a graphics importer cannot be found using the file's type, file name suffix or MIME type, give up immediately without using the slower process of asking every graphics importer to validate the file. This parameter is only used with GetGraphicsImporterForDataRefWithFlags

DISCUSSION

GetGraphicsImporterForDataRef tries to locate a graphics importer component for the specified data reference by checking the file name extension of the file, the file type information, and the MIME type of the file. The file name extension is retrieved from the data reference by use of the DataHGetFileName call to the data handler associated with the data reference.

If it is unable to locate a graphics importer for the file, the returned ComponentInstance is set to nil . If it is able to locate a graphics importer for the data reference, the returned graphics importer ComponentInstance will have already been set up to draw the specified data reference in the current port.

If an importer cannot be found using the file type, file name suffix, or MIME type, GetGraphicsImporterForDataRef will ask each available graphics importer to validate the file, in hopes that one of them can handle files of this type. This can take a long time. If you do not want QuickTime to do this, use the GetGraphicsImporterForDataRefWithFlags function with the flag kDontUseValidateToFindGraphicsImporter.

The caller of GetGraphicsImporterForDataRef is responsible for closing the returned ComponentInstance using CloseComponent .


© 1998 Apple Computer, Inc.

| Previous | Chapter Contents | Chapter Top | Next |